Repository navigation
coverage: an undeclared region is a refusal, not a skipped gate (C-113) - #335
Merged
Polichinel merged 3 commits intoNov 18, 2026
Merged
Conversation
…(C-113) `expected_for(None)` returned None and `excluded_for(None)` returned an empty set — the same values a region that is DECLARED but not pinned returns. So a launch config omitting `region` shipped a delivery whose cell curation and completeness check had both done nothing, reported as a supported configuration. One of the two is supported: `africa_me_legacy` is deliberately unpinned because "complete" is ambiguous there. The other is ADR-003 inference by omission. The refusal goes where this repo already keeps launch declarations, not into a new guard beside the gates: `launch_config.assert_region_declared`, sibling of `assert_contract_mode` and `assert_frame_native_historical`, called from `_read_forecast_data` before any store call. `delivery/coverage.py` holds the same rule at the invariant for every other caller — `RegionNotDeclaredError` on undeclared, None/empty still for declared-but-unpinned. `RegionNotDeclaredError` is not a `CoverageError` subclass, deliberately. Nothing was delivered wrongly; the question could not be asked, and a caller catching CoverageError must not mislabel it as a coverage failure. A second, silent half fixed with it: the count gate logged its skip and the exclusion gate did not, so an uncurated delivery left half its evidence in the run log. Both gates now report their own skip INSIDE the invariant — `assert_complete_coverage` accepts None, `assert_no_excluded_cells` accepts an empty manifest. That is also what let this land: putting the reporting in the managers tripped the 300-line ratchet at 319, and the ratchet was right (C-40 (a)). Both skips are now proven by caplog with no framework at all, and the managers got shorter rather than longer. The entry's warning was the load-bearing part — "a guard refusing any region absent from EXPECTED_CELLS would make africa_me_legacy unlaunchable". The uncommitted falsification stub prescribed exactly that; it is not adopted, and a test now pins the opposite. Also corrects coverage.py's header pointer to a module deleted in #151 — one of the two stale docstring pointers C-107 names. 16 new tests, suite 529 -> 545 passed. C-113 moves to Resolved; Cluster O records its first discharge. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
… misspelling Review and an independent guard audit on this branch both found that the first commit closed the smaller leg and claimed the pair. The forecast leg. Coverage is not asserted in the managers for forecasts: it is asserted in `TargetLease.load`, where the frame exists. Both calls there were wrapped in `if self.excluded_gids:` / `if self.expected_cells is not None:`, so a region that pins neither ran every target with both gates skipped and nothing in the run log. That is the silence C-113 is about, on the leg that does most of the checking. Both `if`s are gone; each gate reports its own skip. A misspelling. `assert_region_declared` accepted any non-empty string, so `region: "lnd_gaul"` passed it, missed both lookups, and skipped both gates while reporting itself as the deliberately-unpinned configuration. KNOWN_REGIONS now declares the regions this delivery recognises, separately from whether a region's cell count is pinned: `africa_me_legacy` is known and still unpinned, and still launches. An unrecognised name raises UnknownRegionError at the invariant and LaunchConfigError at launch, each naming the known set and both repair paths. Two tests from the first commit pinned the old behaviour and are rewritten. The guard audit applied 38 mutations and 7 survived, all at the call sites this change created an obligation for, or in the declaration the invariant trusts: restoring the caller-side `if`s in both managers, adding a fictional region to KNOWN_REGIONS, deleting both ADR-008 `logger.error` calls, deleting the manager call site, and swapping the load-bearing gate order all left the suite green — and one new test asserted something untrue of itself (it claimed the exclusion gate fired where `drop_units` had already removed the cell). All seven are closed: an ast scan of both managers' `_check_coverage`, a cross-check of KNOWN_REGIONS against views-datafactory's own regions.py, two entries in test_env_declaration's _REFUSALS, a parametrised manager source scan, call-order and line-order assertions, and an honest exclusion-gate test. Register: C-113's resolution amended with both findings and the audit. New C-124 — the §6 draws gate catches `Exception` and reports a MemoryError as malformed producer input. Registered, not fixed here, so draws.py stays out of this diff. C-117 and C-123 location notes corrected. 565 passed, 3 skipped, 41 xfailed; ruff clean — measured in the poetry.lock env. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
The entry said what to do and why it was not done on this branch; it did not say where the work now lives. A register entry with no home for its remedy is how C-40's standing-work half became hard to find. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the Tier-2 half of C-113 and the silent half nobody had registered separately.
The defect
expected_for(None)returnedNone;excluded_for(None)returnedfrozenset()— the same values a region that is declared but not pinned returns. So a launch config omittingregionshipped a delivery whose cell curation and completeness check had both done nothing, and it read as a supported configuration.One of those two states is supported:
africa_me_legacyis deliberately unpinned, because with 5 pure-ocean cells "complete" is ambiguous. The other is ADR-003 inference by omission.Where the fix went, and why not where it looks like it belongs
Into
contract/launch_config.py, asassert_region_declared— a sibling ofassert_contract_modeandassert_frame_native_historical, called from_read_forecast_datain both managers before any store call.regionwas the only product-defining launch axis read through a bare.get(); the other two already had declared assertions. This is that module's whole job.delivery/coverage.pyholds the same rule at the invariant, for every other caller (tests,scripts/build_gaul_lookup.py, a future third partner):expected_for/excluded_forraiseRegionNotDeclaredErroron an undeclared region and still returnNone/empty for a declared-but-unpinned one.RegionNotDeclaredErroris not aCoverageErrorsubclass, deliberately — nothing was delivered wrongly, the question could not be asked, and a caller catchingCoverageErrorto report a coverage failure must not catch this and mislabel it.The silent half, fixed with it
The count gate logged its skip. The exclusion gate did not. So a delivery curated by nothing left only half its evidence in the run log — which is why C-113's own Tier rationale ("the count-gate logs a warning before skipping, so the evidence does reach the run log") was true of one gate and not the pair.
Both gates now report their own skip inside the invariant:
assert_complete_coverageacceptsexpected_count=None,assert_no_excluded_cellsan empty manifest, each logging a WARNING naming the leg.That is also what let this land. My first attempt put the reporting in the managers and tripped
test_doc_accuracy's 300-line manager ratchet at 319 lines. The ratchet was right, and C-40(a) says why: logic that can be called with declared arguments belongs where it can be tested without a manager, an Appwrite environment or a views-models path manager. Moving it inward made the managers shorter than before and the skips provable bycaplogwith no framework at all.The entry's warning was the load-bearing part
C-113 said: "A guard written the other way round, refusing any region absent from
EXPECTED_CELLS, would makeafrica_me_legacyunlaunchable."The uncommitted falsification stub from the same day prescribed exactly that — a refusal naming
land_gaulfor any unpinned region. It is not adopted;test_a_declared_region_passes_whether_or_not_it_is_pinnedpins the opposite. The stub's finding was right and its remedy was wrong on one of its two points. It has been moved out oftests/to the session scratchpad rather than deleted.Also
Corrects
coverage.py's header pointer tounfao/extraction.py, deleted in #151 — one of the two stale docstring pointers C-107 names. The other (observed_range.py:6) is untouched and still recorded.Noted, not fixed:
coverage.py's existing raises do not log before raising (ADR-008). I added the module logger for the two skip warnings and left the raises alone rather than widen this change.Verification
ruff checkclean.test_register_integrity.py12 passed; C-113 moved to Resolved, Cluster O records its first discharge, header 39 open / 85 resolved.Noneis what the old silent version did too.🤖 Generated with Claude Code
https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
Update 2026-11-18 — three claims above were wrong, and a guard audit found four more holes
Everything above describes the first commit.
/code-reviewand an independent/falsify guardrun on this branch both found it closed the smaller leg and claimed the pair. Second commit:4604ab2.1. "Both gates now report their own skip" was false on the forecast leg
Forecast coverage is not asserted in the managers at all. It is asserted inside
contract/wire/source_selection.py'sTargetLease.load(), where the frame exists — and there both calls sat behindif self.excluded_gids:andif self.expected_cells is not None:. For a region pinning neither, both conditions were false, so every forecast target loaded with both gates skipped and nothing at all in the run log. The managers'_check_coverage, which the first commit fixed, covers only the historical leg.Both
ifs are gone. The lease calls each gate unconditionally, which is the only form that lets the invariant own its skip report.2. A misspelled region still disabled both gates
assert_region_declaredaccepted any non-empty string. Soregion: "lnd_gaul"passed the launch refusal, missed both dictionary lookups, and skipped both gates — while reporting itself as the deliberately-unpinned configuration. Measured:expected_for("lnd_gaul") -> None,excluded_for("lnd_gaul") -> frozenset(), and a two-cell delivery accepted. One mistyped letter undid exactly what declaring a region is for.C-113 anticipated the wrong guard here — "refusing any region absent from
EXPECTED_CELLS", which would groundafrica_me_legacy— and this is the right one:KNOWN_REGIONS, a declared set of the regions this delivery recognises, kept separate from whether a known region's cell count has been verified.africa_me_legacyis known, still unpinned, still launches, still logs a skipped count-gate. An unrecognised name raisesUnknownRegionErrorat the invariant andLaunchConfigErrorat launch, each naming the known set and both repair paths.Correction to the section above:
test_a_declared_region_passes_whether_or_not_it_is_pinnedasserted thatregion: "not_pinned_anywhere"launches. That generalised correctly fromafrica_me_legacyto the wrong conclusion. It is renamed and narrowed;expected_for("does_not_exist") is Noneis likewise rewritten. Both pinned the defect.3. "before any store call" was imprecise
The historical leg runs first, so the refusal is not the run's first I/O. Both managers' docstrings now say contract-store call, which is what the sentence was about.
4. The guard audit: 38 mutations, 31 caught, 7 survived
Run independently, with no access to the commit message or the register entry. Every mutation against
delivery/coverage.pywas caught — the invariant layer is strongly guarded. All seven survivors were at the call sites this change created an obligation for, or in the declaration the invariant is told to trust. Each left the full suite green:if excluded:/if expected is not None:in both managersastscan: each gate called once in_check_coverage, neither enclosed by anIf"atlantis"toKNOWN_REGIONSsrc/datafactory_query/regions.py, read withast, skipped when no sibling checkoutlogger.errorinassert_region_declaredtest_env_declaration.py::_REFUSALS— the mechanism already existed and the validator had not been added to itassert_region_declaredunfao.pyonly, and listed two of three assertionsleaked = [])drop_unitshad already removed the cell; theCoverageErrorit caught came from the count gateThe pattern is worth keeping: moving skip-reporting out of the two shells and into the invariant was sound and is well guarded. What went unguarded was the shells' remaining obligation to call it — an obligation this change itself created.
Register
Locationcheck would have caught (cross-ref added to C-109).Exceptionaroundnp.asarrayand reports every failure as "malformed input, not a collapsed forecast".MemoryErroris anException, and this path has two measured OOMs behind it (C-32, C-101), so an out-of-memory failure sends the reader to the producer. One line and one test to fix; registered, not fixed here, sodelivery/draws.pystays out of this diff.Verification, re-measured
ruff check .clean.poetry installenvironment matchingpoetry.lock(views-frames 3.0.0,views-pipeline-core 3.4.0), sotest_locked_environmentpasses rather than being skipped around.git statusback to the expected ten files.